class Player(object):  # 类的实例化
    numbers = 0  # 类属性
    max_age = 120  # 类属性
    gender = ["男", "女"]  # 类属性

    def __init__(self, name, age, gender):  # 实例属性
        self.name = name  # 实例属性
        if age > Player.max_age:
            raise Exception("超出最大年龄范围")
        else:
            self.age = age  # 实例属性
        if gender in Player.gender:
            self.gender = gender  # 实例属性

            Player.numbers += 1
        else:
            raise Exception("性别不符规范")

    def __del__(self):  # 析构方法，运行结束时调用
        print("__del__执行")

    def show(self):  # 实例方法
        print(f"我是第{Player.numbers}个运动员，我叫{self.name}")

    def set_honour(self, honour):
        self.honour = honour

    def show_honour(self):
        self.honour.get_honour()

    @classmethod
    def get_players(cls):
        print(f"player的最大年龄不能超过{cls.max_age}")

    @staticmethod
    def isvalid(**kwargs):
        if kwargs["age"] < Player.max_age and kwargs["gender"] in Player.gender:
            return True
        else:
            return False


class Honour(object):
    type_list = []

    def __init__(self, type):
        self.type = type
        Honour.type_list.append(type)

    def get_honour(self):
        print(self.type)

    @classmethod
    def get_all_types(cls):
        for i in Honour.type_list:
            print(i)


class VIP(Player):

    def __init__(self, name, age, gender, level):
        Player.__init__(self, name, age, gender)
        self.level = level

    def show(self):  # 实例方法
        print(f"我是第{Player.numbers}个VIP，我叫{self.name}")


"""
tom = Player("Tom", 20, "男")  # 类的实例化
print(type(tom))
print(isinstance(tom, Player))
tom.job = "篮球运动员"  # 实例属性
print(tom.__dict__)  # 获取对象所有属性,字典类型
print(f"目前共有{Player.numbers}个运动员")
tom.show()
tom.set_honour(Honour('good'))
tom.show_honour()
print(tom.__dict__)  # 获取对象所有属性,字典类型

infos = {"name": "GINNA", "age": 60, "gender": "女"}
if Player.isvalid(**infos):
    Ginna = Player(infos["name"], infos["age"], infos["gender"])
    print(Ginna.__dict__)
"""

tom = VIP("Tom", 20, "男", 90)  # 类的实例化
tom.show()
print(tom.__dict__)
print(Player.numbers)
